package org.lanqiao.practice_3;

import org.junit.Test;

public class TestDriver2 {
	@Test
	public void test() {
		String str = "中国A我";
		// char[]c=str.toCharArray();
		// for (char d : c) {
		// System.out.print(d+" ");
		// }
		trimString(str, 3);
	}

	public static void trimString(String str, int len) {
		byte[] b = str.getBytes();
		int num=0;
		if (b[len - 1] > 0) {
			System.out.println(new String(b, 0, len));
		}else{
			for(int i=0;i<len;i++){
				 if(b[i]<0){
					 num++;
					 num%=2;
				 }else{
					 num=0;
				 }
			}
			if(num==0){
				System.out.println(new String(b,0,len));
			}else{
				System.out.println(new String(b,0,len-1));
			}
		}
		
	}
}
